﻿@model LERP.Domain.Order
@using LERP.Domain
@using LERP.Domain.Enums
@using LERP.Web.Controllers.ViewModels.OrderViewModels
@using Sharp.Framework 
@using Sharp.Framework.Extensions 
@{
    ViewBag.Title = "打印订单";
    Layout = "~/Views/Shared/_EmptyLayout.cshtml";
    var user = (User) ViewBag.Current;
    var page = (int) ViewBag.Page;
    var size = (int) ViewBag.Size;
    var count = Model.Items.Count;
    var pagecount = Math.Max((count + size - 1)/size, 1);
    var list = Model.Items.Skip((page - 1)*size).Take(size).ToList();
    var baseUrl = string.Format("{0}?size={1}", Request.Path,size);
    var paras = string.Join("&", Request.QueryString.AllKeys.Where(x => !string.IsNullOrEmpty(x) && x != "size" && x != "page").Select(x => x + "=" + Request.QueryString[x]).ToList());
    if (!string.IsNullOrEmpty(paras))
    {
        baseUrl = baseUrl+"&" + paras;
        
    }
    var previous = baseUrl + "&page=" + (page - 1);
    var next = baseUrl + "&page=" + (page + 1);
}
 <center><div id="wrapper" style="width: 700px;margin-top: 30px;text-align: left;">
    
<div style="text-align: center;">
       <strong>订单(ORDER)</strong>    
</div>
  <table class="table_input"  style="width: 100%;">
      <tr>
          <th>开单公司名称:</th> 
          <td>@Model.Contract.Subsidiary.Name</td> 
          <th>合同识别号码:</th> 
          <td>@Model.Contract.Code</td>  
          <th></th> 
          <td></td>
      </tr>  
      <tr>
          <th>客户名称:</th> 
          <td>@Model.Customer.Name</td> 
          <th>订货日期:</th> 
          <td>@Model.OrderDate.ToShortDateString()</td> 
          <th>要求交货日期:</th> 
          <td>@Model.ExpectDelivery.ToShortDateString()</td>
      </tr>  
      <tr>
          <th>客户订单号:</th> 
          <td>@Model.CustomerOrderNo</td> 
          <th>交货地点:</th> 
          <td>@Model.Customer.Address</td> 
          <th></th> 
          <td>@("第"+page+"/"+pagecount+"页")</td>
      </tr> 
      @if (!Model.IsGoods)
      {
          <tr>
              <th>订单金额:</th> 
              <td>@Model.Amount</td> 
              <th></th> 
              <td></td> 
              <th></th> 
              <td></td>
          </tr>
      }
    
      </table>
     @if (Model.IsGoods)
     {

         <table class="table_list"  style="width: 99%;">
             <tr>
                 <th style="width: 30px;">序号</th>
                 <th style="width: 80px;">国际条码</th>
                 <th>品名规格</th>
                 <th style="width: 80px;">单价</th>
                 <th style="width: 30px;">单位</th>
                 <th style="width: 60px;">订单数量</th>
             
             </tr>  
             @for (int index = 0; index < list.Count; index++)
             {
                 var item = list[index];
                 <tr>
                     <td>@((page - 1)*size + index+1)</td>
                     <td>@item.Goods.Gencod</td>
                     <td>@item.Goods.Name</td>
                     <td>@item.Price</td>
                     <td>@item.Goods.SellUnit</td>
                     <td>@item.OrderNum</td>
                 </tr>
             }           
         </table>

         <table class="table_list"  style="width: 99%;"> 
             <tr>
                 <td>订单金额:</td>
                 <td>￥@Model.Items.Sum(x => x.Price*x.OrderNum).ToString("0.00")</td>
                 <td>订单箱数：</td>
                 <td>@Model.Items.Sum(x => x.OrderNum)</td>  
                 
                 <td>本页金额:</td>
                 <td>￥@list.Sum(x => x.Price*x.OrderNum).ToString("0.00")</td>
                 <td>本页箱数：</td>
                 <td>@list.Sum(x => x.OrderNum)</td>  
             </tr>     
         </table>

     }
    
    <table class="table_input"  style="width: 100%;">
        <tr>
            <th style="width: 100px;">经理审批:</th> 
            <td style="width: 200px;"></td> 
            <th style="width: 100px;">业务员:</th> 
            <td style="width: 200px;">@Model.Creater.Name</td>  
            <th style="width: 100px;">制单人:</th> 
            <td style="width: 200px;">@user.Name</td>
        </tr>  
        <tr>
            <th colspan="6" style=" text-align: left;">注意:表中单价、金额以实际收款单价和金额。</th>  
        </tr>  
        <tr>
            <th colspan="6" style=" text-align: left;">其他说明：</th>  
        </tr>
    </table> 
</div>  <br/> 
  
    <br/>
<div style="text-align: center"  class="noprint">
    @if (page != 1)
    {
        <a href="@previous" >上一页</a>
    }
  
    <input id="btnPrint" type="button" value="打印" onclick="javascript:window.print();" />
   @if (page != pagecount)
    {
          <a  href="@next" >下一页</a>
    }
</div></center>

<br/>   